<?php

namespace App\Console\Commands;

use Illuminate\Support\Facades\DB;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class SyncDataCommand extends BaseCommand
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'sync:data';
    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = "���˵�/Ȩ�޵Ȼ������ݴӿ�������ͬ������";



    /**
     * Execute the console command.
     *
     * @return void
     */
    public function fire()
    {
        $tables = ["menu", "privilege", "menu_privilege", "dic"];
        foreach ($tables as $table) {
            $sql = "delete from $table";
            DB::statement($sql);

            $sql = "insert into $table select * from remote." . $table;
            DB::statement($sql);
        }

    }


    protected function getArguments()
    {
        return [
            ['table', InputArgument::OPTIONAL, 'specify the table']
        ];
    }

    protected function getOptions()
    {
        return [
            ['skip', "s", InputOption::VALUE_OPTIONAL, 'skip tables matches with the rule'],
        ];
    }
}